﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcAtletIS.Helpers
{
    public static class FilesHelper
    {
        public static SelectList GetFiles(string path, string selectedValue)
        {
            List<SelectListItem> lLogos = new List<SelectListItem>();

            string[] aLogos = System.IO.Directory.GetFiles(path);
            foreach (string sLogo in aLogos)
            {
                SelectListItem sli = new SelectListItem();
                sli.Value = sLogo.Substring(sLogo.LastIndexOf('\\') + 1, sLogo.Length - sLogo.LastIndexOf('\\') - 1);
                sli.Text = sLogo.Substring(sLogo.LastIndexOf('\\') + 1, sLogo.Length - sLogo.LastIndexOf('\\') - 1);
                lLogos.Add(sli);
            }

            if (String.IsNullOrEmpty(selectedValue))
            {
                return new SelectList(lLogos, "Value", "Text");
            }
            else
            {
                return new SelectList(lLogos, "Value", "Text", selectedValue);
            }
        }










    }
}